<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!--<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />-->
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="/Public/favicon.ico" >
<LINK rel="Shortcut Icon" href="/Public/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="/Public/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/Public/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/Public/lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/Public/lib/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="/Public/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/Public/static/h-ui/css/style.css" />
<link rel="stylesheet" href="/Public/css/page.css">

<link href="/Public/dxk/icheck.css" rel="stylesheet">
<script src="/Public/dxk/icheck.js?v=1.0.2"></script>
              
                <script>
                    $(document).ready(function(){
                        $('.user-sex input').each(function(){
                            var self = $(this),
                                    label = self.next(),
                                    label_text = label.text();

                            label.remove();
                            self.iCheck({
                                checkboxClass: 'icheckbox_sm-blue',
                                radioClass: 'radio_sm-blue',
                                insert: label_text
                            });
                        });
                    });
                </script>
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->


<title>添加用户</title>
<link rel="stylesheet" href="http://www.jq22.com/jquery/bootstrap-3.3.4.css">
  <link rel="stylesheet" href="/Public/css/bootstrap-select/dist/css/bootstrap-select.css">
  <script type="text/javascript" src="/Public/lib/jquery/1.9.1/jquery.min.js"></script>
  <script src="http://www.jq22.com/jquery/bootstrap-3.3.4.js"></script>
  <script src="/Public/css/bootstrap-select/dist/js/bootstrap-select.js"></script>
</head>
<body>
<article class="page-container">
	<form action='' method="post" class="form form-horizontal" id="form-member-alert">
		<div class="row cl">
			<input name="userid" type="hidden" value="<?php echo ($user["user_id"]); ?>"/>
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户名：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="<?php echo ($user["user_name"]); ?>" placeholder=""  name="username">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">电话：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="<?php echo ($user["phone"]); ?>" placeholder=""  name="telphone">
			</div>
		</div>

        <div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>OA权限：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select class="select" size="1" name="oaLevel">
					<option value="0" <?php if(($user["oa_level"]) == "0"): ?>selected<?php endif; ?> >无</option>
					<option value="1" <?php if(($user["oa_level"]) == "1"): ?>selected<?php endif; ?> >普通销售员</option>
					<option value="2" <?php if(($user["oa_level"]) == "2"): ?>selected<?php endif; ?> >销售经理</option>
					<option value="3" <?php if(($user["oa_level"]) == "3"): ?>selected<?php endif; ?> >总经理</option>
					<option value="4" <?php if(($user["oa_level"]) == "4"): ?>selected<?php endif; ?> >管理员</option>
				</select>
				</span> </div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>所属区域：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select class="select select-place" size="1" name="place">
					<option value="" selected>请所属区域</option>
					<?php if(is_array($place)): $i = 0; $__LIST__ = $place;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?><option value="<?php echo ($key); ?>" <?php if($key == $user['place']): ?>selected<?php endif; ?>><?php echo ($val); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
				</select>
				</span> </div>
		</div>

        <div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>角色：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select class="select role select-zong" size="1" name="role">
					<option value="<?php echo ($user["level"]); ?>" selected><?php echo (returnRole($user["level"])); ?></option>
				</select>
				</span> </div>
		</div>
		<div class="row cl skin-minimal shenhe" style="display:none">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>负责的银行：</label>
			<select id="first-disabled2" class="selectpicker" multiple data-hide-disabled="true" data-size="5" name="bank[]">
					<option value="" >请选择银行</option>
					<?php if(is_array($banks)): $i = 0; $__LIST__ = $banks;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$ba): $mod = ($i % 2 );++$i;?><option value="<?php echo ($ba["bank_id"]); ?>" <?php if(in_array(($ba["bank_id"]), is_array($user["bank_id"])?$user["bank_id"]:explode(',',$user["bank_id"]))): ?>selected<?php endif; ?>><?php echo ($ba["bank_name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
				</select>
  			</div>
		</volist>
		</div>

		<div class="row cl" >
			<label class="form-label col-xs-4 col-sm-3">直属上级：</label>
				<div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select class="select select-zhi" size="1" name="leader">
					<option value="<?php echo ($user["leader"]); ?>" selected><?php echo (getUsername($user["leader"])); ?></option>
				</select>
				</span> </div>
		</div>

		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>
<script type="text/javascript" src="/Public/lib/layer/2.1/layer.js"></script>

<script type="text/javascript">
$('.select-place').change(function(){
    var place = $(this).val();
    $('.select-zong').empty();
    $('.select-zong').append('<option value="">请选择角色</option>')
    if(place=='1'){
        $('.select-zong').append("<option value='1'>营销人</option><option value='2'>签单人</option><option value='3'>审核人</option><option value='4'>管理员（总经理）</option><option value='12'>总经理</option><option value='10'>副总经理</option><option value='8'>收费人</option><option value='9'>消费部门</option><option value='15'>市区公积金审核</option><option value='16'>抵押他证审核人</option><option value='17'>银行驻场</option>");
    }
    else if(place=='2'){
        $('.select-zong').append("<option value='1'>营销人</option><option value='6'>江宁签单审核人</option><option value='13'>江宁负责人</option><option value='16'>抵押他证审核人</option>");
    }
    else{
        $('.select-zong').append("<option value='1'>营销人</option><option value='11'>江北签单审核</option><option value='14'>江北负责人</option><option value='16'>抵押他证审核人</option>");
    }
})

$('.select-zong').change(function(){
    var len=$('.select-zong option').length;
    var place = $('select[name="place"]').val();
    for(i = 0;i < len;i++){
        if($('.select-zong option').eq(i).is(':selected')){
            var id=$('.select-zong option').eq(i).val();
        }
    }
    $.ajax({
        type:'post',
        url:"<?php echo U('User/zhi');?>",
        data:{id:id,place:place},
        dataType:'json',
        success:function(json){
            console.log(json);
            $('.select-zhi').empty();
            $('.select-zhi').append('<option value="">请选择上级</option>')
            var len=json.length;
            for(i = 0;i <= len;i++){
                $('.select-zhi').append('<option value='+json[i]['user_id']+'>'+json[i]['user_name']+'</option>')
            }
        }
    })
})
var index = parent.layer.getFrameIndex(window.name)
$("#form-member-alert").submit(function(){
  $(".radius").attr('type','button');
        $.ajax({
          url:'<?php echo U("User/editCheck");?>',
          type:'post',
          data:$("#form-member-alert").serialize(),
          dataType:'json',
          success:function(data){
            if(data.ResultCode == '200'){
              layer.msg(data.ResultMessage,{time:1000},function(){
                  parent.window.location.reload()
                  parent.layer.close(index);
              });
            }
            else if(data.ResultCode == '500'){
                layer.msg(data.ResultMessage,{time:1000},function(){

                })
            }
          }
        })
        return false;
	});

	$(function(){
		$('.skin-minimal input').iCheck({
			checkboxClass: 'icheckbox-blue',
			radioClass: 'iradio-blue',
			increaseArea: '20%'
		});
	});
    var val = $('.role').val();
	   if(val == 3 || val == 7 || val == 11){
	       $('.role').parents('.cl').next().css('display','block')
	   }else{
	       $('.role').parents('.cl').next().css('display','none')
	   }
	$('.role').change(function(){
	   var val = $(this).val();
	   if(val == 3 || val == 7 || val == 11 || val==17){
	       $(this).parents('.cl').next().css('display','block')
	   }else{
	       $(this).parents('.cl').next().css('display','none')
	   }
	})
</script>
</body>
</html>